<template>
  <div class="textBox">
    <div class="fliex">
      <van-nav-bar
          title="在线文字转二维码"
          left-text="返回"
          left-arrow
          @click-left="onClickLeft"
      />
    </div>
    <div class="logo">
      <img src="../../assets/logo.png" alt="">
      <h2>在线文字转二维码</h2>
    </div>
    <input type="text" v-model="inputText" placeholder="请输入文字">
    <div class="buttonDiv">
      <button @click="turnFun">点击文字转二维码</button>
    </div>
    <div class="imgBox">
      <img class="textImg" ref="textImg" :src="'https://api.vvhan.com/api/qr?text='+'这是文字转二维码'" alt="">
    </div>
  </div>
</template>


<script>


export default {
  name: "QRcode",
  data() {
    return {
      inputText: '',
    }
  },
  methods: {
    turnFun: function() {
      console.log(this.inputText)

      this.$refs.textImg.src = 'https://api.vvhan.com/api/qr?text=' + this.inputText

    },
    onClickLeft() {
      this.$router.go(-1)
    },

  }
}
</script>

<style scoped lang="less">
.textBox {
  .fliex {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 50px;
  }

  margin: 50px auto;
  padding: 0 20px;

  .logo {
    margin-top: 50px;
    display: flex;
    justify-content: space-around;
    height: 100px;
    line-height: 100px;

    img {
      width: 115px;
    }

    h2 {
      color: @blue;
    }
  }

  input {
    height: 50px;
    line-height: 50px;
    border: 1px solid blue;
    text-indent: 20px;
    border-radius: 8px;
    margin: 28px 0;
    width: 88vw;
  }

  .buttonDiv {
    margin: 28px auto;
    text-align: center;

    button {
      padding: 7px 10px;
      background-color: blue;
      color: white;
      border: 0px;
      border-radius: 7px;
    }
  }

  .imgBox {
    width: 200px;
    height: 200px;
    margin: auto;
    overflow: hidden;

    img {
      width: 200px;
      height: 200px;
    }
  }
}

</style>